import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import requireTransform from 'vite-plugin-require-transform'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
  requireTransform({
    fileRegex: /.js$|.vue$/
  })
  ],
  base: './',
  define: {
    'process.env': {}
  },
  server: {
    host: '0.0.0.0',
    port: 5173,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:8080', //接口域名
        changeOrigin: true,             //是否跨域
        ws: true,  // 允许websocket代理
        // 重写路径 --> 作用与vue配置pathRewrite作用s相同
        rewrite: (path) => path.replace(/^\/api/, "")
      },
      '/media': {
        target: 'http://127.0.0.1:8080', //媒体文件域名
        changeOrigin: true,             //是否跨域
        ws: true
      }
    }
  }
})
